package pica.ui;

import c;
import java.io.PrintStream;
import javax.microedition.lcdui.*;
import pica.core.f;

// Referenced classes of package pica.ui:
//            b, a, f, h

public final class d extends b
{

    public d(f f1, h h1, String s1, int i1, int j1, int k1, int l1)
    {
        super(h1, s1);
        A = 0xffffff;
        B = null;
        r = f1;
        super.e = i1;
        super.f = j1;
        u = i1;
        v = j1;
        super.g = k1;
        s = l1;
        t = k1;
        y = Font.getFont(0, 0, 8);
        z = y.getHeight();
        if(z < 18)
            x = 22;
        else
            x = z + 4;
        i = (s + 5) / x;
        w = f1.b(f1.h(), i - 1);
    }

    protected final void a(Graphics g)
    {
        g.setFont(y);
        b(g);
        int i1 = 10 + super.f;
        if(r.b() > 0)
        {
            w = r.b(r.h(), i - 1);
            for(int j1 = r.h(); j1 < w + 1; j1++)
            {
                pica.ui.a.a(j1 == r.b);
                if(j1 == r.b)
                    a(g, i1);
                Object aobj[];
                if(((Byte)(aobj = r.a(j1))[0]).byteValue() == 1)
                {
                    a(g, aobj, i1);
                    if(!((Boolean)aobj[3]).booleanValue())
                        j1 += ((Integer)aobj[4]).intValue();
                } else
                if(((Byte)aobj[0]).byteValue() == 2)
                    b(g, aobj, i1);
                else
                if(((Byte)aobj[0]).byteValue() == 3)
                    c(g, aobj, i1);
                i1 += x;
            }

        }
    }

    private void b(Graphics g)
    {
        g.setColor(A);
        g.fillRect(u, v, t, s);
        if(B != null)
            g.drawImage(B, u, v, 20);
    }

    private void a(Graphics g, int i1)
    {
        g.setColor(0x96d8ff);
        g.fillRect(0, i1 - x / 2, t, x);
    }

    private void a(Graphics g, Object aobj[], int i1)
    {
        if(((Boolean)aobj[3]).booleanValue())
            f.a(j, 2, i1 - 9, 18, 18, 1, g);
        else
            f.a(j, 2, i1 - 9, 18, 18, 0, g);
        g.setColor(0);
        String s1 = "";
        if(r.a == 1)
            s1 = aobj[1] + " (" + aobj[5] + "/" + aobj[4] + ")";
        else
        if(r.a == 3)
            s1 = (String)aobj[1];
        else
        if(r.a == 6)
            s1 = (String)aobj[1];
        g.drawString(s1, 22, i1 - z / 2, 20);
    }

    private void b(Graphics g, Object aobj[], int i1)
    {
        g.setColor(0);
        if(r.a == 1)
        {
            byte byte0;
            if((byte0 = ((Byte)aobj[2]).byteValue()) == 8)
            {
                if(((String)aobj[7]).equals("wap"))
                    f.a(o, 22, i1 - 9, 18, 18, 2, g);
                else
                if(((String)aobj[7]).equals("msg"))
                    f.a(o, 22, i1 - 9, 18, 18, 0, g);
                else
                if(((String)aobj[7]).equals("ivr"))
                    f.a(o, 22, i1 - 9, 18, 18, 3, g);
                else
                if(((String)aobj[7]).equals("sms"))
                    f.a(o, 22, i1 - 9, 18, 18, 1, g);
                g.drawString((String)aobj[4], 42, i1 - z / 2, 20);
            } else
            {
                if(byte0 == 7 || byte0 == 6 || byte0 == 5)
                    f.a(k, 22, i1 - 9, 18, 18, ((Integer)aobj[5]).intValue(), g);
                else
                    f.a(k, 22, i1 - 9, 18, 18, 9, g);
                if(byte0 == 6)
                    f.a(l, 32, ((i1 + 9) - 10) + 2, 10, 10, 1, g);
                else
                if(byte0 == 5)
                    f.a(l, 32, ((i1 + 9) - 10) + 2, 10, 10, 0, g);
                else
                if(byte0 == 3)
                    f.a(l, 32, ((i1 + 9) - 10) + 2, 10, 10, 2, g);
                if(((Boolean)aobj[6]).booleanValue())
                    f.a(n, 2, i1 - 9, 18, 18, 4, g);
                pica.ui.a.a(g, (String)aobj[4], 42, i1 - z / 2, 20, t - 18 - 2);
                byte byte1;
                if(byte0 != 4)
                    if((byte1 = ((Byte)aobj[7]).byteValue()) == 4)
                        f.a(q, t - 18 - 2, i1 - 9, 18, 18, 1, g);
                    else
                    if(byte1 == 5)
                        f.a(q, t - 18 - 2, i1 - 9, 18, 18, 0, g);
                    else
                    if(byte1 == 1)
                        f.a(q, t - 18 - 2, i1 - 9, 18, 18, 2, g);
            }
            return;
        }
        if(r.a == 3)
        {
            if(((Byte)((Object[])aobj[3])[2]).byteValue() == 1)
            {
                f.a(m, 22, i1 - 9, 18, 18, 3, g);
            } else
            {
                f.a(n, 22, i1 - 9, 18, 18, 0, g);
                if(((Byte)aobj[2]).byteValue() == 3)
                    f.a(l, 33, ((i1 + 9) - 10) + 2, 10, 10, 2, g);
                else
                if(((Byte)aobj[2]).byteValue() == 1)
                    f.a(n, t - 18 - 2, i1 - 9, 18, 18, 2, g);
            }
            String s1 = aobj[5] != null ? aobj[4] + " (" + aobj[5] + ")" : (String)aobj[4];
            g.drawString(s1, 42, i1 - z / 2, 20);
            return;
        }
        if(r.a == 6)
        {
            if(((String)aobj[7]).equals("wap"))
                f.a(o, 22, i1 - 9, 18, 18, 2, g);
            else
            if(((String)aobj[7]).equals("msg"))
                f.a(o, 22, i1 - 9, 18, 18, 0, g);
            else
            if(((String)aobj[7]).equals("ivr"))
                f.a(o, 22, i1 - 9, 18, 18, 3, g);
            else
            if(((String)aobj[7]).equals("sms"))
                f.a(o, 22, i1 - 9, 18, 18, 1, g);
            g.drawString((String)aobj[4], 42, i1 - z / 2, 20);
        }
    }

    private void c(Graphics g, Object aobj[], int i1)
    {
        g.setColor(0);
        if(r.a == 2)
        {
            StringBuffer stringbuffer = new StringBuffer();
            if(((Byte)aobj[10]).byteValue() == 0)
            {
                if(((String)aobj[2]).equals("pica"))
                    f.a(p, 2, i1 - 9, 18, 18, 0, g);
                else
                    f.a(m, 2, i1 - 9, 18, 18, 2, g);
                stringbuffer.append("[");
                stringbuffer.append((String)aobj[3]);
                stringbuffer.append("]");
            } else
            if(((Byte)aobj[10]).byteValue() == 1)
            {
                if(((String)aobj[2]).equals("pica"))
                    f.a(p, 2, i1 - 9, 18, 18, 1, g);
                else
                    f.a(m, 2, i1 - 9, 18, 18, 1, g);
                stringbuffer.append("[");
                stringbuffer.append((String)aobj[3]);
                stringbuffer.append("]");
            } else
            if(((Byte)aobj[10]).byteValue() == 2)
            {
                f.a(m, 2, i1 - 9, 18, 18, 0, g);
                stringbuffer.append(">>>");
            }
            if(((String)aobj[7]).length() > 10)
            {
                stringbuffer.append(((String)aobj[7]).substring(0, 10));
                stringbuffer.append("...");
            } else
            {
                stringbuffer.append((String)aobj[7]);
            }
            pica.ui.a.a(g, stringbuffer.toString(), 22, i1 - z / 2, 20, t);
            return;
        }
        if(r.a == 7)
        {
            StringBuffer stringbuffer1 = new StringBuffer();
            if(((Byte)aobj[10]).byteValue() == 2)
            {
                f.a(m, 2, i1 - 9, 18, 18, 0, g);
                stringbuffer1.append(">>>");
                if((String)aobj[3] != null)
                    stringbuffer1.append((String)aobj[3]);
                else
                    stringbuffer1.append((String)aobj[7]);
            } else
            {
                f.a(o, 2, i1 - 9, 18, 18, 0, g);
                stringbuffer1.append("[");
                stringbuffer1.append((String)aobj[3]);
                stringbuffer1.append("]");
                if(((String)aobj[7]).length() > 10)
                {
                    stringbuffer1.append(((String)aobj[7]).substring(0, 10));
                    stringbuffer1.append("...");
                } else
                {
                    stringbuffer1.append((String)aobj[7]);
                }
            }
            g.drawString(stringbuffer1.toString(), 22, i1 - z / 2, 20);
            return;
        }
        if(r.a == 4)
        {
            if(((Byte)aobj[2]).byteValue() == 1)
            {
                f.a(k, 2, i1 - 9, 18, 18, 9, g);
            } else
            {
                f.a(k, 2, i1 - 9, 18, 18, ((Integer)aobj[5]).intValue(), g);
                if(((Byte)aobj[2]).byteValue() == 2)
                    f.a(l, 12, (i1 + 9) - 5 - 2, 10, 10, 0, g);
            }
            pica.ui.a.a(g, (String)aobj[3], 24, i1 - z / 2, 20, t - 18 - 2);
            if(((String)aobj[4]).equals("owner"))
            {
                f.a(n, t - 18 - 2, i1 - 9, 18, 18, 2, g);
                return;
            }
            if(((String)aobj[4]).equals("admin"))
            {
                f.a(n, t - 18 - 2, i1 - 9, 18, 18, 3, g);
                return;
            }
        } else
        if(r.a == 8)
        {
            if(((String)aobj[1]).indexOf("@cluster.pica") == -1)
            {
                if(((Boolean)aobj[7]).booleanValue())
                    f.a(k, 2, i1 - 9, 18, 18, ((Integer)aobj[6]).intValue(), g);
                else
                    f.a(k, 2, i1 - 9, 18, 18, 9, g);
                pica.ui.a.a(g, (String)aobj[2], 24, i1 - z / 2, 20, t);
                return;
            }
            f.a(n, 2, i1 - 9, 18, 18, 0, g);
            pica.ui.a.a(g, (String)aobj[2], 24, i1 - z / 2, 20, t);
        }
    }

    public final void a()
    {
        r.b = r.b() - 1;
        r.a(r.b, i);
    }

    private void b(int i1)
    {
        Object aobj[];
        switch(i1)
        {
        case -1: 
        case 50: // '2'
            r.d();
            if(r.h() != 0 && r.b == r.h())
            {
                r.e(1);
                w = r.g(w);
            }
            if(r.d(r.b))
                r.a(r.b, i);
            break;

        case -2: 
        case 56: // '8'
            r.e();
            if(!r.d(w) && r.b == w)
            {
                r.f(1);
                w = r.h(w);
            }
            if(r.b == 0)
                r.f();
            break;

        case 49: // '1'
            r.e(i - 1);
            w = r.b(r.h(), i - 1);
            r.b = r.b(r.h(), 1);
            break;

        case 55: // '7'
            r.f(i - 1);
            w = r.b(r.h(), i - 1);
            if(r.d(w))
            {
                r.a(w, i);
                r.b = w;
            } else
            {
                r.b = r.b(r.h(), 1);
            }
            break;

        case -5: 
        case 53: // '5'
            if(((Byte)(aobj = r.a(r.b))[0]).byteValue() == 1)
            {
                r.c(r.b);
                w = r.b(r.h(), i - 1);
                if(!r.d(w) && r.b == w)
                {
                    r.f(1);
                    w = r.h(w);
                }
                F = (short)r.g();
            } else
            if(super.a != null)
                super.a.a(6, new Integer(r.b));
            break;

        case 51: // '3'
            r.a(false);
            break;

        case 57: // '9'
            if(((Byte)r.a(0)[0]).byteValue() == 3)
                a();
            else
                r.a(true);
            break;
        }
        if(super.a != null)
        {
            super.a.a(17, new Integer[] {
                new Integer(r.g()), new Integer(i)
            });
            super.a.a(18, new Integer(r.i()));
        }
        return;
        JVM INSTR dup ;
        Exception exception;
        exception;
        printStackTrace();
    }

    public final int b()
    {
        return r.b;
    }

    public final Object[] a(int i1)
    {
        return r.a(i1);
    }

    public final void a(f f1)
    {
        r = null;
        r = f1;
        w = f1.b(f1.h(), i - 1);
    }

    public static void c()
    {
        try
        {
            k = Image.createImage("/middle/head.png");
            l = Image.createImage("/middle/state.png");
            m = Image.createImage("/middle/msg.png");
            n = Image.createImage("/middle/clustericon.png");
            o = Image.createImage("/middle/channelicon.png");
            p = Image.createImage("/middle/logo.png");
            j = Image.createImage("/middle/group.png");
            q = Image.createImage("/middle/logintype.png");
            return;
        }
        catch(Exception _ex)
        {
            return;
        }
    }

    protected final boolean a(byte byte0, int i1)
    {
        switch(byte0)
        {
        case 0: // '\0'
            b(i1);
            // fall through

        case 2: // '\002'
        default:
            System.out.println("pos:" + r.i());
            break;
        }
        return false;
    }

    protected final boolean a(byte byte0, int i1, int j1)
    {
        if(byte0 == 0)
            return a(i1, j1);
        if(byte0 == 1)
            return c(j1);
        if(byte0 == 2)
            return d();
        else
            return false;
    }

    private boolean c(int i1)
    {
        boolean flag = false;
        if(C)
        {
            int j1 = s / F;
            if(i1 > D)
            {
                if(i1 >= E + j1 && r.i() + i < F)
                {
                    r.f(1);
                    E = (short)i1;
                    if(super.a != null)
                        super.a.a(18, new Integer(r.i()));
                }
            } else
            if(i1 <= E - j1 && r.i() > 0)
            {
                r.e(1);
                E = (short)i1;
                if(super.a != null)
                    super.a.a(18, new Integer(r.i()));
            }
            D = (short)i1;
            flag = true;
        }
        return flag;
    }

    private boolean d()
    {
        D = 0;
        E = 0;
        C = false;
        return true;
    }

    private boolean a(int i1, int j1)
    {
        boolean flag = false;
        if(i1 >= super.g)
        {
            if(f.a(i1, j1, t, v, 10, 10))
                b(49);
            else
            if(f.a(i1, j1, t, (v + s) - 10, 10, 10))
            {
                b(55);
            } else
            {
                C = true;
                D = (short)j1;
                E = (short)j1;
                F = (short)r.g();
                flag = true;
            }
        } else
        if(r.b() > 0)
        {
            int k1;
            if((k1 = (j1 - super.f) / x) >= i - 1)
                k1 = i - 1;
            else
            if(k1 < 0)
                k1 = 0;
            if(f.a(i1, j1, super.e, super.f + k1 * x, t, x))
            {
                r.b = r.b(r.h(), k1);
                e();
                b(-5);
                flag = true;
            }
        }
        return flag;
    }

    private void e()
    {
        super.b.repaint();
        super.b.serviceRepaints();
    }

    private f r;
    private int s;
    private int t;
    private int u;
    private int v;
    private int w;
    public int i;
    private int x;
    public static Image j;
    public static Image k;
    public static Image l;
    public static Image m;
    public static Image n;
    public static Image o;
    public static Image p;
    public static Image q;
    private Font y;
    private int z;
    private int A;
    private Image B;
    private boolean C;
    private short D;
    private short E;
    private short F;
}
